import request from '@/utils/request'

// 查询热搜主题列表
export function listTopic(query) {
  return request({
    url: '/topic/topic/list',
    method: 'get',
    params: query
  })
}

// 查询热搜主题详细
export function getTopic(id) {
  return request({
    url: '/topic/topic/' + id,
    method: 'get'
  })
}

// 新增热搜主题
export function addTopic(data) {
  return request({
    url: '/topic/topic',
    method: 'post',
    data: data
  })
}

// 修改热搜主题
export function updateTopic(data) {
  return request({
    url: '/topic/topic',
    method: 'put',
    data: data
  })
}

// 删除热搜主题
export function delTopic(id) {
  return request({
    url: '/topic/topic/' + id,
    method: 'delete'
  })
}

// 启动爬虫
export function startCrawler(immediate = false) {
  return request({
    url: '/topic/topic/startCrawler',
    method: 'post',
    params: {
      immediate: immediate
    }
  })
}

// 停止爬虫
export function stopCrawler() {
  return request({
    url: '/topic/topic/stopCrawler',
    method: 'post'
  })
}

// 获取爬虫状态
export function getCrawlerStatus() {
  return request({
    url: '/topic/topic/getCrawlerStatus',
    method: 'get'
  })
}

// 获取爬虫配置
export function getCrawlerConfig() {
  return request({
    url: '/topic/topic/getCrawlerConfig',
    method: 'get'
  })
}

// 更新爬虫配置
export function updateCrawlerConfig(data) {
  return request({
    url: '/topic/topic/updateCrawlerConfig',
    method: 'post',
    data: data
  })
}

// 定期清理与导出
export function cleanAndExport(period) {
  return request({
    url: '/topic/topic/clean-and-export',
    method: 'post',
    params: {
      period: period
    }
  })
}
